#ifndef PIPE_MANAGER_H
#define PIPE_MANAGER_H
#include "pipe_module.h"
#include "singleton.h"
#include <map>

class IServer;
class CPipeManager : public utility::network::pipe_manager, public CSingleton<CPipeManager>
{
    friend class CSingleton<CPipeManager>;
    typedef std::map<uint32, IServer *> TServerList;
public:
    //default constructor
    CPipeManager(void);

    // default destructor
    ~CPipeManager(void);

    // when any pipe connected
    virtual void on_connected(utility::network::pipe*);

    // get corresponding server
    IServer * Find(utility::network::PIPEID oPipeId);

    IServer * Find(uint32 nId);

    void Remove(utility::network::PIPEID oPipeId);

    void Remove(uint32 nId);
protected:
    TServerList m_servers;
};

#endif  // endif of PIPE_MANAGER_H
